/**
 * Created with IntelliJ IDEA
 * Description:
 * User:恋恋
 * Date:2022-11-27
 * Time:15:57
 */
class Countable{
    int count;
    synchronized public void add(){
        count++;
    }
}
public class HomeWork {
    public static void main(String[] args) {
        Countable count = new Countable();
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 1_0000; i++) {

                    count.add();

                }
            }
        });
        Thread thread0 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 1_0000; i++) {

                    count.add();

                }
            }
        });
        thread.start();;
        thread0.start();
        try {
            thread.join();
            thread0.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(count.count);
    }
}
